<?php
/**
 * Created by PhpStorm.
 * User: eddy
 * Date: 2019/10/26
 * Time: 0:50
 */

namespace iBrand\Shop\Server\Resources;


use iBrand\Common\Resources\BaseResource;
use iBrand\Shop\Core\Models\Clerk;

class TransferResource extends BaseResource
{
    public function toArray($request)
    {
        $clerk = auth('clerk')->user();

        if ($this->resource->in_shop_id AND $this->resource->in_shop_id == $clerk->shop_id) {
            $this->resource->transfer_type = '调入';
        } else {
            $this->resource->transfer_type = '调出';
            $this->resource->status = 1;
        }

        $this->resource->clerk = '';
        if ($this->resource->clerk_id) {
            $this->resource->clerk = Clerk::find($this->resource->clerk_id);
        }

        return parent::toArray($request);
    }
}